//PassByArray.java
package com.xyc.ch7;
public class PassByArray
{
	public static void main(String[] args)
	{
		int []a={10,4,2,8,5,20,16,1,};
		System.out.print("排序前：");
		for(int i=0;i<a.length;i++)
			System.out.print("  "+a[i]);
		System.out.println();
		selectionSort(a);
		System.out.print("排序后：");
		for(int i=0;i<a.length;i++)
			System.out.print("  "+a[i]);
		System.out.println();
	}

	public static void selectionSort(int[] la)
	{
		int temp,k;
		//int temp1,temp2;
		for(int i=0;i<la.length-1;i++)
		{
			k=i;
			for(int j=i+1;j<la.length;j++)
			{
				if(la[j]<la[k])
					k=j;
			}
			temp=la[i];
			la[i]=la[k];
			//temp1=la[i];
			la[k]=temp;
			//temp2=la[k];
			//System.out.print(la[k]+",");
			//System.out.print(la[i]+",");
		}
	}
}




